<template>
	<view class="">
		<view class="content">
			<view class="title">
				<text>{{data.title}}</text>
				<text class="time">{{data.createtime_text}}</text>
			</view>
			<view class="details">
				<image class="details-img" v-if="data.image" :src="data.image" mode="widthFix" @tap="preview(data.image)"></image>
					<rich-text  v-if="data.content" class="details-content"  :nodes="data.content"></rich-text>
				
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data(){
			return{
				data:{},
				token:'',
			}
		},
		onLoad(e){
			uni.getStorage({
				key: 'token'
			}).then(da => {
				this.token = da[1].data
				if(e.status==0){
					this.init(e.id)
				}else if (e.status == 1){
					this.getDetails(e.id)
				}else if(e.status==2){
					this.stopgas(e.id)
				}
			})
		},
		methods:{
			preview(img){
				uni.previewImage({
					urls:[img]
				})
			},
			init(id){
				var _this = this
				uni.request({
					url: this.$url + 'common.notice/getInfo',
					method: 'POST',
					header:{
						token: this.token
					},
					data: {
						id:id
					},
					success: (res) => {
						if(res.data.code == 1) {
							_this.data = res.data.data
						}
					}
				})
			},
			getDetails(id){
				var _this = this
				uni.request({
					url: this.$url + 'notification.notification/getDetails',
					method: 'POST',
					header:{
						token: this.token
					},
					data: {
						id:id
					},
					success: (res) => {
						if(res.data.code == 1) {
							_this.data = res.data.data
						}
					}
				})
			},
			stopgas(id){
				var _this = this
				uni.request({
					url: this.$url + 'stop.stop_notice/details',
					method: 'POST',
					header:{
						token: this.token
					},
					data: {
						id:id
					},
					success: (res) => {
						if(res.data.code == 1) {
							_this.data = res.data.data
						}
					}
				})
			}
		}
	}
</script>

<style lang="less" scoped>
	.content{
		padding: 40rpx 30rpx;
		display: flex;
		flex-direction: column;
		align-items: center;
		.title{
			width: 100%;
			padding-bottom: 30rpx;
			display: flex;
			align-items: center;
			flex-direction: column;
			border-bottom: 1rpx solid #999999;
			.time{
				color: #999999;
				font-size: 24rpx;
				padding-top: 10rpx;
			}
		}
		.details{
			display: flex;
			flex-direction: column;
			align-items: center;
			.details-img{
				padding: 30rpx;
			}
			.details-content{
				text-align: left;
			}
		}
	}
</style>
